package com.hehao.java_basic.thread;

/**
 * @Author hehao
 * @Date 2022/3/7 21:37
 * @Version
 */

public class StaticProxy {
    public static void main(String[] args) {
        ProxyFunction proxyFunction = new ProxyFunction(new RealFunction());
        proxyFunction.caipiao();
    }
}

interface Happy{
    void caipiao();
}

class RealFunction implements Happy {

    @Override
    public void caipiao() {
        System.out.println("我中了500万！");
    }
}

class ProxyFunction implements Happy{
    private Happy realFunction;

    public ProxyFunction(Happy realFunction) {
        this.realFunction = realFunction;
    }


    @Override
    public void caipiao() {
        System.out.println("购买彩票");
        realFunction.caipiao();
        System.out.println("兑换彩票");
    }
}